package cn.com.cetccst.activation;


import static cn.com.cetccst.tools.kv.CommonKV.kvStore;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;

import cn.com.cetccst.activation.kv.KVKeys;
import cn.com.cetccst.activation.ui.ActivationActivity;
import cn.com.cetccst.tools.log.CommonLogger;

public class ActivationManager {

    private static ActivationManager instance;

    private Callback callback;

    public interface Callback {
        void onResult(boolean success, String message);
    }

    public static void initialize(Context context) {
        CommonLogger.initialize(context);
        instance = new ActivationManager();
    }

    public static ActivationManager get() {
        return instance;
    }

    public boolean isActivated() {
        //TODO 临时写的，具体业务再具体分析
//        return false;
        return !TextUtils.isEmpty(kvStore.decodeString(KVKeys.KEY_ACCESS_TOKEN));
    }

    public void startActivation(Activity activity, Callback callback) {
        this.callback = callback;
        Intent intent = new Intent(activity, ActivationActivity.class);
        activity.startActivity(intent);
    }

    public Callback getCallback() {
        return callback;
    }
}
